/*
 * @Author: wangming
 * @Date: 2020-09-09 14:50:17
 * @LastEditors: wangming
 * @LastEditTime: 2022-05-13 15:09:09
 * @Description: file content
 */
import Vue from 'vue';
import template from './ruleEditor/ruleEditor.vue';
import storeform from "@/store";
class CreateInstance {
  static instance = null
  static getFormListInTree = []
  static create(item) {
    if (!!item) {
      this.getFormListInTree = [item, ...storeform.getters.getFormListInTree]
    } else {
      this.getFormListInTree = [...storeform.getters.getFormListInTree]
    }
    if (!this.instance) {
      const BenConstructor = Vue.extend(template);
      this.instance = new BenConstructor({
        el: document.createElement('div'),
      });
      document.body.appendChild(this.instance.$el);
    }
  }

  static editModule(editValue, item) {
    this.create(item);
    return this.instance.enitinit(editValue, this.getFormListInTree);
  }
  static addModule(item) {
    this.create(item);
    return this.instance.init(this.getFormListInTree);
  }

}
export default CreateInstance;
